<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <include file="public:meta" />
    <link href="../public/css/common.css" rel="stylesheet" type="text/css" />
    <link href="../public/css/suggest.css" rel="stylesheet" type="text/css" />
    <qscms:load type="category"/>
</head>
<body>
<include file="public:header" />
<div class="all_body">
    <div class="suggest_main">
        <div class="suggest_head">您的建议让我们每天变的更好</div>
        <div class="top_tips">用户您好，请将您的意见、想法、建议或投诉内容告诉我们，以帮助我们为全体用户提供更加优质的服务。我们将在第一时间及时回复您的反馈，如您的问题比较紧急，请致电服务热线：{:C('qscms_bootom_tel')}。</div>
        <div class="suggest_list_group">
            <div class="suggest_list_cell">
                <div class="list_cell_left">意见类型</div>
                <div class="list_cell_right">
                    <div class="suggest_type_cell"><div class="suggest_type selected" data-code="1">建议</div></div>
                    <div class="suggest_type_cell"><div class="suggest_type" data-code="2">意见</div></div>
                    <div class="suggest_type_cell"><div class="suggest_type" data-code="3">求助</div></div>
                    <div class="suggest_type_cell"><div class="suggest_type" data-code="4">投诉</div></div>
                    <div class="clear"></div>
                    <input type="hidden" name="infotype" value="1"  />
                </div>
                <div class="clear"></div>
            </div>
            <div class="suggest_list_cell">
                <div class="list_cell_left">联系方式</div>
                <div class="list_cell_right"><input type="text" class="suggest_input" name="tel" placeholder="请输入您的QQ、邮箱或者电话以便和您沟通，您的信息仅工作人员可见！"></div>
                <div class="clear"></div>
            </div>
            <div class="suggest_list_cell">
                <div class="list_cell_left">反馈内容</div>
                <div class="list_cell_right">
                    <textarea class="suggest_area" id="suggest_feedback" name="feedback" placeholder="请详细描述您遇到的问题，有助于我们快速定位并解决问题"></textarea>
                </div>
                <div class="clear"></div>
            </div>
            <div class="suggest_list_cell">
                <div class="list_cell_left"></div>
                <div class="list_cell_right">
                    <input type="button" class="btn_yellow suggest_btn" id="J_suggest_submit" value="提 交" />
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="J_suggest_verify" value="{$varify_suggest}" />
<input type="button" id="btnCheck" style="display:none;">
<div id="popup-captcha"></div>
<include file="public:footer_min" />
<script src="http://static.geetest.com/static/tools/gt.js"></script>
<script type="text/javascript">
    // 意见类型切换
    $('.suggest_type').click(function(event) {
        $('.suggest_type').each(function(index, el) {
            $(this).removeClass('selected');
        });
        $(this).addClass('selected');
        $('input[name="infotype"]').val($(this).data('code'));
    });
    // 提交验证
    $('#J_suggest_submit').die().live('click', function(event) {
        var typeValue = $.trim($('input[name="infotype"]').val());
        var telValue = $.trim($('input[name="tel"]').val());
        var feedbackValue = $.trim($('#suggest_feedback').val());
        if (typeValue == "") {
            disapperTooltip("remind", "请选择意见类型");
            return false;
        }
        if (telValue == "") {
            disapperTooltip("remind", "请填写联系方式");
            return false;
        }
        if (telValue != "" && telValue.length > 30) {
            disapperTooltip("remind", "联系方式不能超出30个字");
            return false;
        }
        if (feedbackValue == "") {
            disapperTooltip("remind", "请填写反馈内容");
            return false;
        }
        if (eval($('#J_suggest_verify').val())) {console.log('极验');
            $("#btnCheck").click();
        } else {
            $('#J_suggest_submit').val('提 交 中...').addClass('btn_disabled').prop('disabled', !0);
            doSuggestFun();
        }
    });

    function doSuggestFun() {
        var typeValue = $.trim($('input[name="infotype"]').val());
        var telValue = $.trim($('input[name="tel"]').val());
        var feedbackValue = $.trim($('#suggest_feedback').val());
        // 提交表单
        $.ajax({
            url: "{:U('Suggest/index')}",
            type: 'POST',
            dataType: 'json',
            data: {infotype: typeValue, tel: telValue, feedback: feedbackValue}
        })
        .done(function(data) {
            if (parseInt(data.status)) {
                disapperTooltip("success", data.msg);
                setTimeout(function () {
                    window.location.reload();
                }, 2000);
            } else {
                $('#J_suggest_submit').val('提 交').removeClass('btn_disabled').prop('disabled', 0);
                disapperTooltip("remind", data.msg);
            }
        })
        .fail(function(result) {
            $('#J_suggest_submit').val('提 交').removeClass('btn_disabled').prop('disabled', 0);
            disapperTooltip("remind", result.msg);
        });
    }
    if (eval($('#J_suggest_verify').val())) {console.log(eval($('#J_suggest_verify').val()));
        $.ajax({
            // 获取id，challenge，success（是否启用failback）
            url: qscms.root+'?m=Home&c=Captcha&t=' + (new Date()).getTime(), // 加随机数防止缓存
            type: "get",
            dataType: "json",
            success: function (data) {
                // 使用initGeetest接口
                // 参数1：配置参数
                // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
                initGeetest({
                    gt: data.gt,
                    challenge: data.challenge,
                    product: "popup", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                    offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
                }, handler);
            }
        });
        var handler = function(captchaObj) {
            captchaObj.appendTo("#popup-captcha");
            captchaObj.bindOn("#btnCheck");
            captchaObj.onSuccess(function() {
                $('#J_suggest_submit').val('提 交 中...').addClass('btn_disabled').prop('disabled', !0);
                doSuggestFun();
            });
            captchaObj.onFail(function() {
                $('#J_suggest_submit').val('提 交').removeClass('btn_disabled').prop('disabled', 0);
            });
            captchaObj.onError(function() {
                $('#J_suggest_submit').val('提 交').removeClass('btn_disabled').prop('disabled', 0);
            });
            captchaObj.getValidate()
        };
    }
</script>
</body>
</html>